//
//  StatusCellBottomView.swift
//  微博个人swift
//
//  Created by 李灏 on 16/2/19.
//  Copyright © 2016年 lh. All rights reserved.
//

import UIKit
import SnapKit

class StatusCellBottomView: UIView {
    
    @objc private func repostBtnDidClick() {
        let tempView:TempViewController = TempViewController()
        
        navViewController()?.pushViewController(tempView, animated: true)
  
    }
    //重写构造方法
    override init(frame: CGRect) {
        super.init(frame: frame)
        self.backgroundColor = UIColor(white: 0.96, alpha: 1)
        setupUI()
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    //设置界面
    private func setupUI() {
        addSubview(repostBtn)
        addSubview(commentBtn)
        addSubview(oYeahBtn)
        
        //自动布局
        repostBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(self.snp_left)
            make.top.equalTo(self.snp_top)
            make.bottom.equalTo(self.snp_bottom)

        }
        
        commentBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.top.equalTo(repostBtn.snp_top)
            make.bottom.equalTo(repostBtn.snp_bottom)
            make.width.equalTo(repostBtn.snp_width)
        }
        
        oYeahBtn.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.top.equalTo(repostBtn.snp_top)
            make.bottom.equalTo(repostBtn.snp_bottom)
            
            //三等分
            make.right.equalTo(self.snp_right)
            make.width.equalTo(commentBtn.snp_width)
        }
        //加分割线
        let sepView1 = sepView()
        let sepView2 = sepView()
        addSubview(sepView1)
        addSubview(sepView2)
        //约束
        sepView1.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(repostBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(0.5)
            //黄金分割比  1 : 0.618
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        sepView2.snp_makeConstraints { (make) -> Void in
            make.left.equalTo(commentBtn.snp_right)
            make.centerY.equalTo(self.snp_centerY)
            make.width.equalTo(0.5)
            make.height.equalTo(self.snp_height).multipliedBy(0.4)
        }
        repostBtn.addTarget(self, action: "repostBtnDidClick", forControlEvents: .TouchUpInside)
    }
    
    private func sepView() ->UIView {
        let v:UIView = UIView()
        v.backgroundColor = UIColor.darkGrayColor()
        return v
    }
    
    //懒加载按钮
    private lazy var repostBtn:UIButton = UIButton(backImageName: nil, title: "转发", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_retweet")
    
    private lazy var commentBtn:UIButton = UIButton(backImageName: nil, title: "评论", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_comment")
    
    private lazy var oYeahBtn:UIButton = UIButton(backImageName: nil, title: "赞", textColor: UIColor.lightGrayColor(), imageName: "timeline_icon_unlike")
}
